package com.ruoyi.project.platform.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.platform.domain.PltUserSymbol;
import com.ruoyi.project.platform.service.IPltUserSymbolService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 用户币对Controller
 * 
 * @author ruoyi
 * @date 2020-07-27
 */
@RestController
@RequestMapping("/platform/symbol")
public class PltUserSymbolController extends BaseController
{
    @Autowired
    private IPltUserSymbolService pltUserSymbolService;

    /**
     * 查询用户币对列表
     */
    @PreAuthorize("@ss.hasPermi('platform:symbol:list')")
    @GetMapping("/list")
    public TableDataInfo list(PltUserSymbol pltUserSymbol)
    {
        startPage();
        List<PltUserSymbol> list = pltUserSymbolService.selectPltUserSymbolList(pltUserSymbol);
        return getDataTable(list);
    }

    /**
     * 导出用户币对列表
     */
    @PreAuthorize("@ss.hasPermi('platform:symbol:export')")
    @Log(title = "用户币对", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(PltUserSymbol pltUserSymbol)
    {
        List<PltUserSymbol> list = pltUserSymbolService.selectPltUserSymbolList(pltUserSymbol);
        ExcelUtil<PltUserSymbol> util = new ExcelUtil<PltUserSymbol>(PltUserSymbol.class);
        return util.exportExcel(list, "symbol");
    }

    /**
     * 获取用户币对详细信息
     */
    @PreAuthorize("@ss.hasPermi('platform:symbol:query')")
    @GetMapping(value = "/{symbolId}")
    public AjaxResult getInfo(@PathVariable("symbolId") Long symbolId)
    {
        return AjaxResult.success(pltUserSymbolService.selectPltUserSymbolById(symbolId));
    }

    /**
     * 新增用户币对
     */
    @PreAuthorize("@ss.hasPermi('platform:symbol:add')")
    @Log(title = "用户币对", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PltUserSymbol pltUserSymbol)
    {
        return toAjax(pltUserSymbolService.insertPltUserSymbol(pltUserSymbol));
    }

    /**
     * 修改用户币对
     */
    @PreAuthorize("@ss.hasPermi('platform:symbol:edit')")
    @Log(title = "用户币对", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PltUserSymbol pltUserSymbol)
    {
        return toAjax(pltUserSymbolService.updatePltUserSymbol(pltUserSymbol));
    }

    /**
     * 删除用户币对
     */
    @PreAuthorize("@ss.hasPermi('platform:symbol:remove')")
    @Log(title = "用户币对", businessType = BusinessType.DELETE)
	@DeleteMapping("/{symbolIds}")
    public AjaxResult remove(@PathVariable Long[] symbolIds)
    {
        return toAjax(pltUserSymbolService.deletePltUserSymbolByIds(symbolIds));
    }
}
